import numpy as np

img_arr = np.array(
    [[1, 2, 3, 4],
     [5, 6, 7, 8],
     [9, 10, 11, 12],
     [13, 14, 15, 16]]
)

# 1.进行填充
img_fill_arr = np.array(
    [[6, 5, 6, 7, 8, 7],
     [2, 1, 2, 3, 4, 3],
     [6, 5, 6, 7, 8, 7],
     [10, 9, 10, 11, 12, 11],
     [14, 13, 14, 15, 16, 15],
     [10, 9, 10, 11, 12, 11]]
)

# 2.特定大小的均值滤波和
mean_value = np.array([
    [1/9, 1/9, 1/9],
    [1/9, 1/9, 1/9],
    [1/9, 1/9, 1/9]
])

# 3.在填充好的图像上进行不断欢动计算
for i in range(4):
    for j in range(4):
        img_cut = img_fill_arr[i:i+3, j:j+3]
        img_arr[i, j] = np.sum(img_cut * mean_value)
        print(img_cut)
        print(img_cut * mean_value)
        print(np.sum(img_cut * mean_value))

print(img_arr)
